{extend name="base" /} {block name="body"}
<div class="layui-tab layui-tab-brief">
    <ul class="layui-tab-title">
        <li class="layui-this">新增广告</li>
    </ul>
</div>
<!--tab标签-->
<div class="layui-tab-brief">
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <form class="layui-form form-container" action="{:url('admin/ad/save')}" data-url="{:url('admin/ad/save')}"
                  method="post" localtion-url="{:url('admin/ad/index')}">
                <div class="layui-row layui-col-space15 layui-form-item">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">广告位置</label>
                        <div class="layui-input-block">
                            <select lay-verify="required" name="location_id" lay-filter="location_id">
                                {volist name="category_list" id="vo"}
                                <option value="{$vo.location_id}">{$vo.title}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">广告名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" placeholder="请输入名称" required lay-verify="required"
                                   autocomplete="off" class="layui-input" value="">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">链接地址</label>
                        <div class="layui-input-block">
                            <input type="text" name="link" placeholder="请填写带http://的全路径" required lay-verify="required"
                                   autocomplete="off" class="layui-input" value="">
                        </div>
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">Logo</label>
                    <div class="layui-input-inline" style="width: auto;    margin-right:0px">
                        <button type="button" class="layui-btn uploadlogo"  id="banner-up-btn">
                            <i class="layui-icon"></i>上传图片
                        </button>
                        <input class="layui-upload-file" type="file" accept="undefined" name="file">
                    </div>
                    <div class="layui-input-inline" style="width: calc(100% - 234px);">
                        <input type="text" id="banner_path" name="banner_path" placeholder="建议尺寸1500*100" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"></label>
                    <div class="layui-upload-list">
                        <img class="layui-upload-img" id="banner_show" style="max-height: 100px;max-width: 100%">
                    </div>
                </div>

                <div class="layui-row layui-col-space15 layui-form-item">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">联系QQ</label>
                        <div class="layui-input-block">
                            <input type="text" name="poster_qq" placeholder="请输入名称" required lay-verify="required"
                                   autocomplete="off" class="layui-input" value="">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">开始时间</label>
                        <div class="layui-input-block">
                            <input type="text" id="start_time"  name="start_time" required lay-verify="required"
                                   autocomplete="off" class="layui-input" value="">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">结束时间</label>
                        <div class="layui-input-block">
                            <input type="text" id="finish_time"  name="finish_time"  required lay-verify="required"
                                   autocomplete="off" class="layui-input" value="">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">费用</label>
                        <div class="layui-input-block">
                            <input type="number" name="money"  required lay-verify="required"
                                   autocomplete="off" class="layui-input" value="">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">描述</label>
                    <div class="layui-input-block">
                        <input type="text" name="description" autocomplete="off" class="layui-input" value="">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">排序</label>
                    <div class="layui-input-inline">
                        <input type="text" name="sort" autocomplete="off" class="layui-input" value="0">
                    </div>
                    <div class="label-tint">数值越大越靠前</div>
                </div>
                <div class="btable-paged">
                    <div class="formbtngroup">
                        <button class="layui-btn layui-btn-sm" lay-submit="" type="submit" lay-filter="formadd">添加
                        </button>
                        <button onclick="history.go(-1);return false;" class="layui-btn layui-btn-primary layui-btn-sm">
                            返回
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

{/block} {block name="script"}
<script type="text/javascript" src="__ADMIN__/js/formadd.js"></script>
<script>
    layui.use(['form', 'upload','laydate'], function () {
        var form = layui.form,
            jq = layui.jquery;
        var upload = layui.upload;
        var laydate = layui.laydate;

        laydate.render({
            elem: '#start_time' //指定元素
        });

        laydate.render({
            elem: '#finish_time' //指定元素
        });
        var uploadInst = upload.render({
            elem: '#banner-up-btn' //绑定元素
            , url: '{:url("upload/upimage")}' //上传接口
            , done: function (res) {
                layer.msg(res.msg, {
                    icon: 1,
                    time: 1000
                });
                jq("#banner_path").val(res.data.src);
                jq('#banner_show').attr('src', res.data.src);
            },
            error: function (res) {
                layer.msg(res.msg, {
                    icon: 2,
                    time: 1000
                });
            }
        });
    })
</script>
{/block}